<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<script>
/**
 * 
 * 注意：此组件为库存模块：货号查找使用组件
 *
 */

var pbSet = new Set();
function searchpbs(){	
		var barcode = $("#barcode").val();
		

			 $('#dataGridBrand').datagrid({
		    		url : 'productJSONAction!listProductsDataByPage',    		
		    	    queryParams: {
		    	    	'formBean.productBarcode.product.productCode':barcode,    	    	
		    	    },
		    		fit : true,
		    		fitColumns : true,
		    		pagination : true,
		    		pageSize : 15,
		    		pageList : [ 15, 20],
		    		border : false,
		    		checkOnSelect : true,
		    		selectOnCheck : true,
		    		singleSelect: false,
		    		showFooter:true,
		    		rownumbers:true,
		    		nowrap : false,
		    		columns : [[
		    					{field:'id', width:40,title:'选择',checkbox: true},	
		    				
		    					{field:'productCode', width:90,title:'货号',fixed:true},	
		    					{field:'color', width:70,title:'颜色',fixed:true},
								{field:'categoryLevel', width:70,title:'产品线',fixed:true},
								{field:'category', width:150,title:'货品种类',fixed:true},						
								{field:'brand', width:140,title:'品牌',fixed:true},	
								{field:'supplier', width:150,title:'厂家',fixed:true},	
								{field:'year', width:70,title:'年',fixed:true},	
								{field:'quarter', width:70,title:'季度',fixed:true},	
								{field:'unit', width:70,title:'单位',fixed:true},	
								{field:'wholePrice1', width:70,title:'预设价1',fixed:true},	
								{field:'wholePrice2', width:70,title:'预设价2',fixed:true},	
								 {				
									field : 'action',
									title : '选择',
									width : 60,
								formatter : function(value, row, index) {							
									var str = '';
									str += $.formatString('<a href="#" onclick="selectBrand(\'{0}\');"><img border="0" src="{1}" title="货品"/></a>', row.barcode,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/select.png');
									return str;
								}},
		    			     ]],	    
		    	});
		        
		        $("#productDialog").dialog("open");
		
     
}
//选中货品
function selectBrand(barcode){

	console.log("选择条码："+barcode);

	//已选货品数量信息
	let brandNums = pbSet.size;	

	var storeId = $("#storeId").val();
    var params= "formBean.pb.barcode=" + barcode + "&formBean.storeId="+storeId ; 
    $.post("action/headqInventoryFlowJSONAction!scanByBarcodeInvenFlowOrder",params, insertBkProcess,"json");
	$("#productDialog").dialog("close");
	
}



//所有checkbox 选中的货品
function selectpbs(){
	
	var rows = $('#dataGridBrand').datagrid('getChecked');
	var storeId = $("#storeId").val();
	if(rows.length != 0){
		for(let i = 0;i<rows.length;i++){
			var barcode = rows[i].barcode;			
		    var params= "formBean.pb.barcode=" + barcode + "&formBean.storeId="+storeId ; 
		    $.post("action/headqInventoryFlowJSONAction!scanByBarcodeInvenFlowOrder",params, insertBkProcess,"json");
		
		}
	}
	$("#productDialog").dialog("close");
}

</script>

<s:form id="barcodeForm" name="barcodeForm" action="" theme="simple" method="POST">
<strong>输入：</strong><s:textfield cssClass="easyui-searchbox" id="barcode" data-options="prompt:'请输入货号/条码',searcher:insert"  size="16" />			

</s:form>

<!-- 查找货品 -->
<div id="productDialog" class="easyui-dialog" style="width: 1200px; height: 550px" data-options="title:'查找货品',modal:false,closed:true,resizable:true">	
			<a onclick="selectpbs();" href="javascript:void(0);" class="easyui-linkbutton c5" style="height:25px;" data-options="">确认选择</a>
		    <div id="cc" class="easyui-layout" style="width:1180px;height:470px; position: relative; top:5px;">
		    
		    	<table id="dataGridBrand" border="0" >
				</table>
		    </div>
</div>
